home *** CD-ROM | disk | FTP | other *** search
- package javax.crypto;
-
- import java.security.AlgorithmParameters;
- import java.security.InvalidAlgorithmParameterException;
- import java.security.InvalidKeyException;
- import java.security.Key;
- import java.security.NoSuchAlgorithmException;
- import java.security.NoSuchProviderException;
- import java.security.Provider;
- import java.security.spec.AlgorithmParameterSpec;
- import sun.security.jca.GetInstance;
-
- public class ExemptionMechanism {
- private Provider provider;
- private ExemptionMechanismSpi exmechSpi;
- private String mechanism;
- private boolean done = false;
- private boolean initialized = false;
- private Key keyStored = null;
-
- protected ExemptionMechanism(ExemptionMechanismSpi var1, Provider var2, String var3) {
- this.exmechSpi = var1;
- this.provider = var2;
- this.mechanism = var3;
- }
-
- public final String getName() {
- return this.mechanism;
- }
-
- public static final ExemptionMechanism getInstance(String var0) throws NoSuchAlgorithmException {
- GetInstance.Instance var1 = SunJCE_b.a("ExemptionMechanism", ExemptionMechanismSpi.class, var0);
- return new ExemptionMechanism((ExemptionMechanismSpi)var1.impl, var1.provider, var0);
- }
-
- public static final ExemptionMechanism getInstance(String var0, String var1) throws NoSuchAlgorithmException, NoSuchProviderException {
- GetInstance.Instance var2 = SunJCE_b.a("ExemptionMechanism", ExemptionMechanismSpi.class, var0, var1);
- return new ExemptionMechanism((ExemptionMechanismSpi)var2.impl, var2.provider, var0);
- }
-
- public static final ExemptionMechanism getInstance(String var0, Provider var1) throws NoSuchAlgorithmException {
- GetInstance.Instance var2 = SunJCE_b.a("ExemptionMechanism", ExemptionMechanismSpi.class, var0, var1);
- return new ExemptionMechanism((ExemptionMechanismSpi)var2.impl, var2.provider, var0);
- }
-
- public final Provider getProvider() {
- return this.provider;
- }
-
- public final boolean isCryptoAllowed(Key var1) throws ExemptionMechanismException {
- boolean var2 = false;
- if (this.done && var1 != null) {
- var2 = this.keyStored.equals(var1);
- }
-
- return var2;
- }
-
- public final int getOutputSize(int var1) throws IllegalStateException {
- if (!this.initialized) {
- throw new IllegalStateException("ExemptionMechanism not initialized");
- } else if (var1 < 0) {
- throw new IllegalArgumentException("Input size must be equal to or greater than zero");
- } else {
- return this.exmechSpi.engineGetOutputSize(var1);
- }
- }
-
- public final void init(Key var1) throws InvalidKeyException, ExemptionMechanismException {
- this.done = false;
- this.initialized = false;
- this.keyStored = var1;
- this.exmechSpi.engineInit(var1);
- this.initialized = true;
- }
-
- public final void init(Key var1, AlgorithmParameterSpec var2) throws InvalidKeyException, InvalidAlgorithmParameterException, ExemptionMechanismException {
- this.done = false;
- this.initialized = false;
- this.keyStored = var1;
- this.exmechSpi.engineInit(var1, var2);
- this.initialized = true;
- }
-
- public final void init(Key var1, AlgorithmParameters var2) throws InvalidKeyException, InvalidAlgorithmParameterException, ExemptionMechanismException {
- this.done = false;
- this.initialized = false;
- this.keyStored = var1;
- this.exmechSpi.engineInit(var1, var2);
- this.initialized = true;
- }
-
- public final byte[] genExemptionBlob() throws IllegalStateException, ExemptionMechanismException {
- if (!this.initialized) {
- throw new IllegalStateException("ExemptionMechanism not initialized");
- } else {
- byte[] var1 = this.exmechSpi.engineGenExemptionBlob();
- this.done = true;
- return var1;
- }
- }
-
- public final int genExemptionBlob(byte[] var1) throws IllegalStateException, ShortBufferException, ExemptionMechanismException {
- if (!this.initialized) {
- throw new IllegalStateException("ExemptionMechanism not initialized");
- } else {
- int var2 = this.exmechSpi.engineGenExemptionBlob(var1, 0);
- this.done = true;
- return var2;
- }
- }
-
- public final int genExemptionBlob(byte[] var1, int var2) throws IllegalStateException, ShortBufferException, ExemptionMechanismException {
- if (!this.initialized) {
- throw new IllegalStateException("ExemptionMechanism not initialized");
- } else {
- int var3 = this.exmechSpi.engineGenExemptionBlob(var1, var2);
- this.done = true;
- return var3;
- }
- }
-
- protected void finalize() {
- this.keyStored = null;
- }
- }
-